/**
 *
 */
package br.com.portal.fitness.model;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 * @author rodolfo.julio
 *
 */
@Entity
@Table(name = "PERFIL")
@NamedQueries({
    @NamedQuery(name = Perfil.FIND_BY_DESC, query = "select u from Perfil u where u.descricao = :desc"),
    @NamedQuery(name = Perfil.FIND_ALL, query = "SELECT b FROM Perfil b")
})
public class Perfil implements Serializable {

    /**
     *
     */
    private static final long serialVersionUID = -1023913900026484875L;

    public static final String FIND_ALL = "Perfil.findAll";
    public static final String FIND_BY_DESC = "Perfil.findByDescricao";

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id")
    private Long id;

    @Column(name = "descricao", nullable = false)
    private String descricao;

//    @ManyToOne
//    @JoinColumn(name = "sistema_id", nullable = false)
//    private Sistema sistema;

    @Column(name = "id_usuario_padrao")
    private Integer idUsuarioPadrao;

    /**
     *
     */
    public Perfil() {

    }

    public Perfil(Long id, String descricao,
            Integer idUsuarioPadrao) {
        super();
        this.id = id;
        this.descricao = descricao;
        this.idUsuarioPadrao = idUsuarioPadrao;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result
                + ((descricao == null) ? 0 : descricao.hashCode());
        result = prime * result + ((id == null) ? 0 : id.hashCode());
        result = prime * result
                + ((idUsuarioPadrao == null) ? 0 : idUsuarioPadrao.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        Perfil other = (Perfil) obj;
        if (descricao == null) {
            if (other.descricao != null) {
                return false;
            }
        } else if (!descricao.equals(other.descricao)) {
            return false;
        }
        if (id == null) {
            if (other.id != null) {
                return false;
            }
        } else if (!id.equals(other.id)) {
            return false;
        }
        if (idUsuarioPadrao == null) {
            if (other.idUsuarioPadrao != null) {
                return false;
            }
        } else if (!idUsuarioPadrao.equals(other.idUsuarioPadrao)) {
            return false;
        }

        return true;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getDescricao() {
        return descricao;
    }

    public void setDescricao(String descricao) {
        this.descricao = descricao;
    }

    public Integer getIdUsuarioPadrao() {
        return idUsuarioPadrao;
    }

    public void setIdUsuarioPadrao(Integer idUsuarioPadrao) {
        this.idUsuarioPadrao = idUsuarioPadrao;
    }

}
